package com.settlement.system.csv;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author author
 */
public class Headers {

    private List<Header> headers;
    private List<String> titles;
    private List<String> fields;

    public Headers(List<Header> headers) {
        this.headers = headers;
        parse();
    }

    private void parse() {
        Collections.sort(this.headers);
        titles = new ArrayList<>();
        fields = new ArrayList<>();
        for (Header header : headers) {
            titles.add(header.getTitle());
            fields.add(header.getField());
        }
    }

    public List<String> getTitles() {
        return titles;
    }

    public List<String> getFields() {
        return fields;
    }

    public Header getHeader(Integer index){
        if(index < headers.size() && index >= 0){
            return headers.get(index);
        }
        return null;
    }

    public List<Header> getHeaders() {
        return headers;
    }
}
